package com.junchenrobot.mes.boot;

import com.junchenrobot.mes.dao.InputTaskDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * 任务取出线程
 *
 * @author SeaWave
 * @date 2022/11/01
 */
// @Component
public class TakeInputTaskRunner implements CommandLineRunner {
    
    private final InputTaskDao inputTaskDao;
    
    // private final WcsClient wcsClient;
    
    private final ThreadPoolTaskExecutor threadPoolTaskExecutor;
    
    @Autowired
    public TakeInputTaskRunner(InputTaskDao inputTaskDao,
                               ThreadPoolTaskExecutor threadPoolTaskExecutor) {
        this.inputTaskDao = inputTaskDao;
        // this.wcsClient = wcsClient;
        this.threadPoolTaskExecutor = threadPoolTaskExecutor;
    }
    
    @Override
    public void run(String... args) throws Exception {
        // 执行取出异步线程
        threadPoolTaskExecutor.execute(new InputTaskThread(inputTaskDao));
    }
}
